<template>
  <descriptions :columns="descriptionsList" :data-source="details" style="padding: 15px" :col-span="24" />
</template>

<script>
import { msgNoticeDetails } from '@gis/lib/api';
import { handleCommonRes } from '@gis/lib/utils/resolver.js';
import { useDicDataStore } from '@gis/lib/pinia/dicData.js';

export default {
  name: 'msg-notice-details',
  props: {
    id: { type: [String, Number] },
  },
  data() {
    return {
      details: {},
      descriptionsList: [
        { label: '大类', key: 'big_type', format: (v) => this.getDicData('D0137')[v] || '-' },
        { label: '小类', key: 'small_type',format: (v) => this.getDicData(this.details.big_type)[v] || '-' },
        { label: '细类', key: 'fine_type',format: (v) => this.getDicData(this.details.small_type)[v] || '-' },
        { label: '标题', key: 'title' },
        { label: '描述', key: 'content' },
        { label: '时间', key: 'create_time' },
      ],
    };
  },
  created() {
    this.getDetails();
  },
  methods: {
    async getDetails() {
      const data = await handleCommonRes(msgNoticeDetails, { id: this.id });
      this.details = data && data.length ? data[0] : {};
    },
  },
  setup() {
    const { getDicData } = useDicDataStore();
    return { getDicData };
  },
};
</script>

<style scoped></style>
